package approval.dao;

import java.sql.ResultSet;
import java.util.ArrayList;

import models.util.MySqlDataAccessHelper;

import resource.pojo.DepartmentLang;

public class DepartmentLangDAO {
	public static ArrayList<DepartmentLang> getListDepartment(String lang){
		ArrayList<DepartmentLang> lst = new ArrayList<DepartmentLang>();
		MySqlDataAccessHelper mysql = new MySqlDataAccessHelper();
		String sql = "SELECT * FROM department_lang where LangID='"+lang+"' ORDER BY DepartmentName ASC";
		try {
			mysql.open();
			ResultSet rs = mysql.executeQuery(sql);
			while(rs.next()){
				lst.add( new DepartmentLang(
						rs.getInt("IDDepartment"),
						rs.getString("LangID"),
						rs.getString("DepartmentName"),
						rs.getString("Location"),
						rs.getString("Description")));
			}
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			mysql.close();
		}
		return lst;
	}
}
